import request from '@/utils/request';
import { isArrayOf, isObjectMaybe } from '@/utils/types';
export interface ProductAbstract {
    id: string;
    name: string;
    type: string;
}
export interface Product extends ProductAbstract {
    color: string;
    version: string;
}
export const isProductAbstract = (u: unknown): u is ProductAbstract => {
    return (
        isObjectMaybe<ProductAbstract>(u) &&
        typeof u.id === 'string' &&
        typeof u.name === 'string' &&
        typeof u.type === 'string'
    );
};
export const isProduct = (u: unknown): u is Product => {
    return (
        isObjectMaybe<Product>(u) &&
        typeof u.id === 'string' &&
        typeof u.name === 'string' &&
        typeof u.type === 'string' &&
        typeof u.color === 'string' &&
        typeof u.version === 'string'
    );
};
export const isProductAbstractArray = (u: unknown): u is ProductAbstract[] => {
    return isArrayOf(u, isProductAbstract);
};
// 查询所有产品列表
export function getAllProducts() {
    return request({
        url: '/products',
        method: 'get',
    });
}

// 查询产品详细
export function getProduct(id: string) {
    return request({
        url: `/product/${id}`,
        method: 'get',
    });
}
